package com.example.javachatroomextend.mapper;

import com.example.javachatroomextend.model.Message;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper {
    @Select("select * from message where sessionId=#{sessionId} order by postTime desc limit 100")
    List<Message> getMessageBySessionId(@Param("sessionId") Integer sessionId);

    @Insert("insert into message values(null,#{sessionId},#{fromId},#{content},now())")
    Integer addMessage(@Param("sessionId") Integer sessionId,@Param("fromId") Integer fromId,@Param("content") String content);
}
